<?php

namespace api\department\controller;

use cmf\controller\RestAdminBaseController;

class UserController extends RestAdminBaseController
{
    function select_h5()
    {
        $admin_id = $this->userId;
        $where = [];
        if ($admin_id != 1) {
            $where['dep.id'] = ['in', getUsersGroup($admin_id)];
        }
        $id = $this->request->param('id', 0, 'intval');

        $where['user_status'] = ['neq',0];
        $lists = db('user')
            ->alias('user')
            ->join('__DEPARTMENT_USER__ dep_user', 'user.id = dep_user.user_id')
            ->join('__DEPARTMENT__ dep', 'dep_user.dep_id = dep.id')
            ->where($where)
            ->field([
                'user.*',
                'dep.name as dep_name,dep.id as dep_id'
            ])->where($where)->select();

        $view = get_view();

        $view->assign('header',[
            'token' => $this->token,
            'device' => $this->deviceType
        ]);
        $view->assign('lists', $lists);
        $view->assign('id', $id);
        echo $view->fetch();
        die;
    }
}